package com.dzm.content.listener;

import com.dzm.constants.RabbitConstant;
import com.dzm.constants.RedisConstant;
import com.dzm.content.entity.Content;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * 作者：Dzm
 * 时间：2024-09-16-11:12
 * 功能：
 */

@Component
@RabbitListener(queues = RabbitConstant.CONTENT_SAVE)
public class SaveContentListener {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @RabbitHandler
    public void save(Content content) {
        redisTemplate.opsForHash().put(RedisConstant.BANNER_LIST, content.getId().toString(), content);
    }
}
